/*
*******************************************************************************
*                              (c) Copyright HighSun Techonology Company
*                                           All Rights Reserved
*
* File    : freq_cal.h
* By      : HuangXi
* Version : V0.1
* Datetime: 2012-02-22 PM 22:22
* Description: MACRO Defines and function declare
*******************************************************************************
*/

#ifndef _FREQ_TEST_H__
#define _FREQ_TEST_H__

#include <includes.h>



/*---------- ECCTL1 ( ECAP Control Reg 1) ----------*/
/* CAPxPOL bits */
#define EC_RISING      0x0
#define EC_FALLING     0x1

/* CTRRSTx bits*/
#define EC_ABS_MODE    0x0
#define EC_DELTA_MODE  0x1

/* PRESCALE bits*/
#define EC_BYPASS      0x0
#define EC_DIV1        0x0
#define EC_DIV2        0x1
#define EC_DIV4        0x2
#define EC_DIV6        0x3
#define EC_DIV8        0x4
#define EC_DIV10       0x5


/*---------- ECCTL2 ( ECAP Control Reg 2) ----------*/
/* CONT/ONESHOT bit*/
#define EC_CONTINUOUS  0x0
#define EC_ONESHOT     0x1

/* STOPVALUE bit*/
#define EC_EVENT1      0x0
#define EC_EVENT2      0x1
#define EC_EVENT3      0x2
#define EC_EVENT4      0x3

/* RE-ARM bit*/
#define EC_ARM         0x1

/* TSCTRSTOP bit*/
#define EC_FREEZE      0x0
#define EC_RUN         0x1
#define EC_STOP        0x0


/* CTRRSTx bits*/
#define EC_ABS_MODE    0x0
#define EC_DELTA_MODE  0x1

/* PRESCALE bits*/
#define EC_BYPASS      0x0
#define EC_DIV1        0x0
#define EC_DIV2        0x1
#define EC_DIV4        0x2
#define EC_DIV6        0x3
#define EC_DIV8        0x4
#define EC_DIV10       0x5




/* SYNCO_SEL bit*/
#define EC_SYNCIN     0x0
#define EC_CTR_PRD    0x1
#define EC_SYNCO_DIS  0x2

/* CAP/APWM mode bit*/
#define EC_CAP_MODE   0x0
#define EC_APWM_MODE  0x1

/* APWMPOL bit*/
#define EC_ACTV_HI    0x0
#define EC_ACTV_LO    0x1

/* Generic*/
#define EC_DISABLE    0x0
#define EC_ENABLE     0x1
#define EC_FORCE      0x1

/* Wrap CAP1-CAP4 */
#define WRAP_CAP1          0x0
#define FREE_SOFT_MODE     0x3


/************************* Function Declare ****************************/
void   cap1_init(void);
Uint32 get_freq(void);
Uint32 get_last_head(void);
Uint32 get_head(void);
Uint32 get_prev_freq_cal(void);
Uint32 get_freq_cal(void);
void   set_prev_freq_cal(Uint32 freq_counter);

#endif /*#ifndef _FREQ_TEST_H__*/

